cmake_minimum_required(VERSION 3.5)

project(Chicken)

set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)

add_executable(chicken ${SOURCES})

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

if(APPLE)
    set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
elseif(UNIX)
    set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
endif()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

set(INSTALL_DIR "${CMAKE_BINARY_DIR}/install")

find_package(Doxygen)
if(DOXYGEN_FOUND)
    set(DOXYGEN_INPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
    set(DOXYGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/doc)
    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
    add_custom_target(docs ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
                      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
                      COMMENT "Generating API documentation with Doxygen" VERBATIM)
endif()

install(TARGETS chicken DESTINATION ${INSTALL_DIR}/bin)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${INSTALL_DIR}/include)
